<?php

class CGridView extends BaseView{
	public $parent=NULL;
	public function __construct($p){
		$this->parent=&$p;
	}
	
	
	public function render($query,$p){
		global $db,$app;
		
		$app->addCSS('grid');
		$app->addJS('grid');
		
		$rs=$db->query($query);
		echo "<table border='1' class='ffwd_grid'><thead><tr>";
		foreach($p['fields'] as $k=>$v){
			echo "<th>";
			echo $v;
			echo "</th>";
		}
		echo "</tr></thead><tbody>";
		while($row=$rs->fetch_assoc()){
			echo "<tr>";
			foreach($p['fields'] as $k=>$v){		
				echo "<td>";
				echo $row[$v];
				echo "</td>";
			};
			echo "</tr>";
		};
		echo "</tbody></table>";
	}
}